/*******************************************************************************
*  file    : rpcserver.hpp
*  created : 18.08.2013
*  author  : 
*******************************************************************************/

#ifndef RPCSERVER_HPP
#define RPCSERVER_HPP

#include <QObject>
#include <QVariant>
#include <QScopedPointer>

class XmlRpcServer;
class DeferredResult;
class ModemManager;

class RpcServer : public QObject
{
    Q_OBJECT
public:
    explicit RpcServer(QObject *parent = 0);
    RpcServer(const QString &address, quint16 port, QObject *parent);
    ~RpcServer();
    bool isListening();

    QString address() const;
    void    setAddress(const QString& address);
    quint16 port() const;
    void    setPort(const quint16& port);

public slots: //External API
    QVariant modemStatus     ();
    QVariant addMole         (const QVariant& v);
    QVariant updateMole      (const QVariant& v);
    QVariant getMoleList     ();
    QVariant hideMoles       (const QVariant& num_idx);
    QVariant addSmsToOutgoing(const QVariant& num_idx, const QVariant& txt);
    QVariant sendInfoRequest (const QVariant& num_idx);
    QVariant sendPosRequest  (const QVariant& num_idx);
    QVariant sendModeRequest (const QVariant& num_idx, const QVariant& mode);

    QVariant getLastInfo     (const QVariant& num_idx);
    QVariant getWorkedTasks  (const QVariant& num_idx);

public slots:
    void start();
private slots:
    void stop();
private:
    void initServer();
private:
    QScopedPointer<XmlRpcServer>  srv_;
    QString                       address_;
    quint16                       port_;
};

#endif // RPCSERVER_HPP
